package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.domain.SysPoint;
import com.ruoyi.system.service.ISysPointService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 钓点 信息操作处理
 *
 * @author kevin
 */
@Controller
@RequestMapping("/system/point")
public class SysPointController extends BaseController
{
    private String prefix = "system/point";

    @Autowired
    private ISysPointService pointService;

    @RequiresPermissions("system:point:view")
    @GetMapping()
    public String point()
    {
        return prefix + "/point";
    }

    /**
     * 查询钓点列表
     */
    @RequiresPermissions("system:point:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysPoint point)
    {
        startPage();
        List<SysPoint> list = pointService.selectPointList(point);
        return getDataTable(list);
    }

    /**
     * 新增钓点
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存钓点
     */
    @RequiresPermissions("system:point:add")
    @Log(title = "钓点", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated SysPoint point)
    {
        point.setCreateBy(getLoginName());
        return toAjax(pointService.insertPoint(point));
    }
}
